package org.zfes.snowier.zbss.xzy.mo.dtos.api;

import java.io.Serializable;
import java.util.Date;


/**
 * api接口监控参数模型
 * 
 *
 */
public class ApiMonitorDto implements Serializable {
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;

	protected String apiDesc;
	
	protected String apiKey;
	
	 private java.util.Date date;
	
	protected String instanceKey;
	
	protected Byte returnStatus;
	
	protected String requestUrl;
	
	protected String contentType;
	
	protected Long contentLength;
	
	protected String method;
	
	protected String sesssionid;
	
	protected String clientip;
	
	/**
	 * api接口请求开始时间
	 */
	protected Date startTime;
	/**
	 * api接口请求开始时间
	 */
	protected Long startTimeLong;
	/**
	 * api接口请求结束时间
	 */
	protected Date endTime;
	/**
	 * api接口请求结束时间
	 */
	protected Long endTimeLong;
	
	/**
	 * api接口请求耗时: 毫秒
	 */
	protected Long consumingTime;

	/**
	 * api接口请求参数入参
	 */
	protected String requestParam;
	/**
	 * api接口请求出参
	 */
	protected String responseValue;
	
	/**
	 * api接口请求异常消息,错误栈
	 */
	protected String exceptionStack;
	
	
	
//	public ApiMonitorDto(HttpServletRequest request) {
//		super();
//		Date now = new Date();
//		
//		
//		this.requestUrl = request.getRequestURI();
//		this.contentLength = request.getContentLengthLong();
//		this.method = request.getMethod();
//		this.sesssionid = request.getSession().getId();
//		//this.requestParam = HttpRequestUtil.getParamMap(request);
//		this.clientip = MIPUtil.getClientIpAddr(request);
//		this.startTime  = now;
//		this.startTimeLong = now.getTime();
//	}
	
	public ApiMonitorDto() {
		super();
	
	}
//	public ApiMonitorDto(ApiMoniotr ann) {
//		this.apiDesc = ann.desc();
//		this.apiKey = ann.key();
//		
//	}
//	public ApiMonitorDto merge(ApiMonitorDto newDto) {
//		BeanUtils.copyProperties(newDto, this);
//		this.consumingTime = this.endTimeLong - this.startTimeLong;
//		return this;
//		
//	}
	
	
//	public ApiMonitorDto parseAnn(ApiMoniotr ann) {
//		this.apiDesc = ann.desc();
//		this.apiKey = ann.key();
//		return this;
//		
//	}

	public ApiMonitorDto(String requestUrl, String contentType, Long contentLength,
			String method, String sesssionid, String apiDesc, String apiKey, Date startTime, Long startTimeLong, Date endTime,
			Long endTimeLong, Long consumingTime, String requestParam,String responseValue,
			String exceptionStack, String clientip) {
		super();
		this.requestUrl = requestUrl;
		this.contentType = contentType;
		this.contentLength = contentLength;
		this.method = method;
		this.sesssionid = sesssionid;
		this.apiDesc = apiDesc;
		this.apiKey = apiKey;
		this.startTime = startTime;
		this.startTimeLong = startTimeLong;
		this.endTime = endTime;
		this.endTimeLong = endTimeLong;
		this.consumingTime = consumingTime;
		this.requestParam = requestParam;
		this.responseValue = responseValue;
		this.exceptionStack = exceptionStack;
		this.clientip = clientip;
	}


	

	public String getRequestUrl() {
		return requestUrl;
	}

	public ApiMonitorDto setRequestUrl(String requestUrl) {
		this.requestUrl = requestUrl;
		return this;
	}

	public String getContentType() {
		return contentType;
	}

	public ApiMonitorDto setContentType(String contentType) {
		this.contentType = contentType;
		return this;
	}

	public Long getContentLength() {
		return contentLength;
	}

	public ApiMonitorDto setContentLength(Long contentLength) {
		this.contentLength = contentLength;
		return this;
	}

	public String getMethod() {
		return method;
	}

	public ApiMonitorDto setMethod(String method) {
		this.method = method;
		return this;
	}

	public String getSesssionid() {
		return sesssionid;
	}

	public ApiMonitorDto setSesssionid(String sesssionid) {
		this.sesssionid = sesssionid;
		return this;
	}



	public Date getStartTime() {
		return startTime;
	}

	public ApiMonitorDto setStartTime(Date startTime) {
		this.startTime = startTime;
		return this;
	}

	public Long getStartTimeLong() {
		return startTimeLong;
	}

	public ApiMonitorDto setStartTimeLong(Long startTimeLong) {
		this.startTimeLong = startTimeLong;
		return this;
	}

	public Date getEndTime() {
		return endTime;
	}

	public ApiMonitorDto setEndTime(Date endTime) {
		this.endTime = endTime;
		return this;
	}

	public Long getEndTimeLong() {
		return endTimeLong;
	}

	public ApiMonitorDto setEndTimeLong(Long endTimeLong) {
		this.endTimeLong = endTimeLong;
		return this;
	}

	public Long getConsumingTime() {
		return consumingTime;
	}

	public ApiMonitorDto setConsumingTime(Long consumingTime) {
		this.consumingTime = consumingTime;
		return this;
	}

	public String getRequestParam() {
		return requestParam;
	}

	public ApiMonitorDto setRequestParam(String requestParam) {
		this.requestParam = requestParam;
		return this;
	}

	public String getResponseValue() {
		return responseValue;
	}

	public ApiMonitorDto setResponseValue(String responseValue) {
		this.responseValue = responseValue;
		return this;
	}

	public String getExceptionStack() {
		return exceptionStack;
	}

	public ApiMonitorDto setExceptionStack(String exceptionStack) {
		this.exceptionStack = exceptionStack;
		return this;
	}

	public String getClientip() {
		return clientip;
	}

	public ApiMonitorDto setClientip(String clientip) {
		this.clientip = clientip;
		return this;
	}

	public Byte getReturnStatus() {
		return returnStatus;
	}

	public ApiMonitorDto setReturnStatus(Byte returnStatus) {
		this.returnStatus = returnStatus;
		return this;
	}

	public String getInstanceKey() {
		return instanceKey;
	}

	public ApiMonitorDto setInstanceKey(String instanceKey) {
		this.instanceKey = instanceKey;
		return this;
	}
	public String getApiDesc() {
		return apiDesc;
	}
	public ApiMonitorDto setApiDesc(String apiDesc) {
		this.apiDesc = apiDesc;
		return this;
	}
	public String getApiKey() {
		return apiKey;
	}
	public ApiMonitorDto setApiKey(String apiKey) {
		this.apiKey = apiKey;
		return this;
	}
	public java.util.Date getDate() {
		return date;
	}
	public ApiMonitorDto setDate(java.util.Date date) {
		this.date = date;
		return this;
	}
	@Override
	public String toString() {
		return "ApiMonitorDto [apiDesc=" + apiDesc + ", apiKey=" + apiKey + ", date=" + date + ", instanceKey="
				+ instanceKey + ", returnStatus=" + returnStatus + ", requestUrl=" + requestUrl + ", contentType="
				+ contentType + ", contentLength=" + contentLength + ", method=" + method + ", sesssionid=" + sesssionid
				+ ", clientip=" + clientip + ", startTime=" + startTime + ", startTimeLong=" + startTimeLong
				+ ", endTime=" + endTime + ", endTimeLong=" + endTimeLong + ", consumingTime=" + consumingTime
				+ ", requestParam=" + requestParam + ", responseValue=" + responseValue + ", exceptionStack="
				+ exceptionStack + "]";
	}



}
